<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .box {
      margin: 100px auto;
      width: 100px;
      height: 40px;
      line-height: 40px;
      background: pink;
    }

    .wrap {
      position: relative;
      padding-left: 100%;
      width: 0;
      height: 100%;
    }

    span {
      display: inline-block;
      white-space: nowrap;
    }
  </style>
</head>

<body>
  <div class="box">
    <div class="wrap">
      <span>你好你好你的哈哈哈哈哈哈哈啊啊啊啊啊</span>
    </div>
  </div>
  <script>
    const wrap = document.querySelector('.wrap');
    let wrapWidth = wrap.offsetWidth;
    const spanWidth = document.querySelector("span").offsetWidth;


    // wrap.style.transition = 'all  0.5s';
    let width = 0
    function move() {
      width += 1
      console.log(width);
      if (width >= wrapWidth + spanWidth) {
        wrap.style.transform = 'translateX(0px )'
        return
      }
      wrap.style.transform = `translateX(-${width}px)`
      requestAnimationFrame(move)
    }
    move()
  </script>
</body>

</html>